﻿@model WeekWin
<div class="main">
    @*@Html.Action("Banner")
    @Html.Action("Scroll")*@
    <div class="strdeprocess">
        <div class="line"></div>
        <ul>
            <li>
                <i>1</i>
                <span>申请操盘资金</span>
            </li>
            <li>
                <i class="cur">2</i>
                <span>支付保证金</span>
            </li>
            <li>
                <i>3</i>
                <span>操盘申请成功</span>
            </li>
            <li>
                <i>4</i>
                <span>开始投资股票</span>
            </li>
            <li class="last">
                <i>5</i>
                <span>盈利七成归您</span>
            </li>

        </ul>
    </div>
    <div class="traderbox">
        <div class="content confirm">
            <div class="t">支付风险保证金</div>
            <div class="c">
                <p>
                    支付风险保证金 <em>@ViewBag.RiskMargin</em>元
                </p>
            </div>
            @if (ViewBag.BalanceAmount != null)
            {
                decimal a = ViewBag.RiskMargin - ViewBag.BalanceAmount;
                <div class="ac" id="BalanceAmount">
                     @if (a <= 0)
                     {
                         <span>您的账户余额：@(ViewBag.BalanceAmount)元</span>
                     }
                     else
                     {
                         <span>您的账户余额只剩@(ViewBag.BalanceAmount)元，本次支付还差@(a)元，<a class="blue" target="_blank" href='@Url.DomainRouteUrl(AreasConfig.Web, new {controller = "pay", action = "index", id = ViewBag.CurentUser.UserId})'>马上充值</a></span>
                     }
                </div>
            }
            else
            {
                <div class="ac" id="BalanceAmount"></div>
            }
            <p>
                <input type="button" id="DetermineBtn" class="button red" value="确定操盘" />
                <input type="button" id="BackUpdate" class="button grey" value="返回修改" style="margin-left: 10px;" />
            </p>
            <div class="left">
                <div class="firminput">
                    <p class="i">
                        <em>@Model.FirmCapital</em>元
                    </p>
                    <p>实盘资金</p>
                </div>
            </div>
            <div class="right">
                <ul>
                    <li>
                        <b>操盘须知</b>
                        <span style="line-height: 25px;">@Html.Raw(MathProject.GetLismit(Model.FirmCapital))</span>
                    </li>
                    <li>
                        <b>风险保证金</b>
                        <span>
                            <em>@Model.RiskMargin.MoneyFormat()</em>元
                        </span>
                    </li>
                    <li>
                        <b>总操盘资金</b>
                        <span><em>@Model.TotalTrade.MoneyFormat()</em>元</span>
                    </li>
                    <li>
                        <b>亏损警戒线</b>
                        <span><em>@Model.LossWarLine.MoneyFormat()</em>元</span>
                    </li>
                    <li>
                        <b>亏损平仓线</b>
                        <span><em style="color: #cd1818">@Model.LossOpenLine.MoneyFormat()</em>元</span>
                    </li>
                    <li>
                        <b>资金使用期限</b>
                        <span><i>5</i>个交易日</span>
                    </li>
                    <li>
                        <b>账户管理费</b>
                        <span>完全免费</span>

                    </li>
                    <li>
                        <b>开始交易时间</b>
                        <span>
                            @(Model.StartTime==0?"今天":"下个交易日")
                        </span>
                    </li>
                </ul>
            </div>

        </div>
    </div>
    @{Html.RenderPartial("Info");}
</div>
<script type="text/javascript">
    $(function() {
        $("#BackUpdate").bind("click", function() {
            window.location.href = "@Url.DomainRouteUrl(AreasConfig.Web, new { controller = "weekwin", action = "index", param = string.Format("FirmCapital={0}&RiskMargin={1}&TotalTrade={2}&LossWarLine={3}&LossOpenLine={4}&ManageMoney={5}&StartTime={6}&Type={7}", Model.FirmCapital, Model.RiskMargin, Model.TotalTrade, Model.LossWarLine, Model.LossOpenLine, Model.ManageMoney, Model.StartTime,Model.Type) })";
        });

        var postProject = function() {
            $.jajax({
                url: "@Url.DomainRouteUrl(AreasConfig.Web, "PostConfirm", "WeekWin")",
                params: {
                    FirmCapital: "@Model.FirmCapital",
                    RiskMargin: "@Model.RiskMargin",
                    TotalTrade: "@Model.TotalTrade",
                    LossWarLine: "@Model.LossWarLine",
                    LossOpenLine: "@Model.LossOpenLine",
                    ManageMoney: "@Model.ManageMoney",
                    StartTime: "@Model.StartTime",
                    FundTime: 5
                },
                callback: function(ret) {
                    if (!ret) {
                        return;
                    }
                    if (ret.data == 3) { //账户余额不足
                        $.StockWindow({
                            title: "账户余额不足",
                            id: "PostProject-Window",
                            classes: "project",
                            content: '<label>您的账户余额不足，请先充值</label><label><a target="_blank" class="button recharge" href="@Url.DomainRouteUrl(AreasConfig.Web, new { controller = "pay", action = "index", id = (ViewBag.CurentUser!=null?ViewBag.CurentUser.UserId:0) })">立即充值</a><a class="button recharge un" href="javascript:$(\'#PostProject-Window\').CloseWindow()">暂不充值</a></label>'
                        });
                    }
                    if (ret.message == "ok" && ret.data > 0) {
                        window.location.href = "/weekwin/seccess/" + ret.data;
                    }
                }
            });
        };
    //确定操盘
    $("#DetermineBtn").bind("click", function() {
        if (!$.isLogin()) {
            login.load(function() {
                postProject();
            });
        } else {
            postProject();
        }
    });
    });
</script>